<div class="popup_body">
    <div class="ui_table">
        <form method="post">
            <table cellpadding="0" cellspacing="0">
                <#if Session['SESSION_KEY_USER'].type != Session['USER_TYPE_AGENCY'].value>
                    <tr>
                        <#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_PLATFORM'].value>
                            <td align="right">运营商：</td>
                            <td>
                                <#--<input name="agentId" required="true" id="agent_id_${pid}" class="easyui-combotree"
                                       editable="false" style="width: 184px; height: 28px;"
                                       data-options="url:'${contextPath}/security/basic/agent/tree.htm',
                                        method:'get',
                                        valueField:'id',
                                        textField:'text',
                                        editable:false,
                                        multiple:false,
                                        panelHeight:'auto'
                                    "
                                >-->
                                <input name="agentId" class="easyui-combotree" editable="false"
                                       style="width: 184px; height: 28px;" id="agent_id_${pid}"
                                       data-options="url:'${contextPath}/security/basic/agent/tree.htm?',
                                        method:'get',onSelect: function(rec){
                                           var url = '${contextPath}/security/hdw/agency/tree.htm?agentId='+rec.id;
                                           $('#agency_id_${pid}').combotree('reload', url);
                                           },
                                        onChange:function(){
                                           $('#agency_id_${pid}').combotree('clear');
                                           },
                                        panelHeight:'auto'
                                "/>
                            </td>
                        </#if>
                        <#if Session['SESSION_KEY_USER'].type != Session['USER_TYPE_AGENCY'].value>
                            <td align="right">代理商：</td>
                            <td>
                                <input name="agencyId" class="easyui-combotree" editable="false"
                                       style="width: 184px; height: 28px;" id="agency_id_${pid}"
                                       data-options="<#if Session['SESSION_KEY_USER'].agentId??&&Session['SESSION_KEY_USER'].agentId!=0>url:'${contextPath}/security/hdw/agency/tree.htm?agentId=${Session['SESSION_KEY_USER'].agentId}',</#if>method:'get'"
                                />
                            </td>
                        </#if>
                    </tr>
                </#if>
                <tr>
                    <td width="70" align="right">套餐名称：</td>
                    <td><input id="duration" class="text easyui-validatebox" name="priceName"
                               style="width:168px;height:28px " required="true"></td>
                </tr>
                <tr>
                    <td width="70" align="right">价格(元)：</td>
                    <td><input id="price_${pid}" class="easyui-numberspinner" style="width:180px;height: 30px "
                               required="required" data-options="min:0.01,precision:2">
                    </td>
                    <td align="right">类型：</td>
                <#if types??>
                    <td>
                        <#list types as type>
                            <input type="radio"  class="radio" <#if type.getValue()==1>checked </#if>name="type" required
                                   value="${type.getValue()}"/>${type.getName()}
                        </#list>
                    </td>
                </#if>
                </tr>
                <tr>
                    <td width="70" align="right">次数：</td>
                    <td><input type="text" maxlength="6" class="easyui-numberspinner" id="radio1"
                               style="width: 180px; height: 28px;" required="required" name="number"
                               data-options="min:1,max:100"/></td>
                    <td width="70" align="right">天数：</td>
                    <td><input type="text" maxlength="6" class="easyui-numberspinner" id="radio2" hidden
                               style="width: 180px; height: 28px;" required="required" name="dayCount"
                               data-options="min:1"/></td>
                </tr>
                <tr>
                    <td width="120" align="right">日使用上限：</td>
                    <td><input type="text" maxlength="6" class="easyui-numberspinner" id="radio3" hidden
                               style="width: 180px; height: 28px;" required="required" name="dayUse"
                               data-options="min:1"/></td>
                    <td align="right" >备注：</td>
                    <td><textarea style="width:200px;" maxlength="120" name="memo"></textarea></td>
                </tr>
            </table>
        </form>
    </div>
</div>
<div class="popup_btn">
    <button class="btn btn_red ok">确定</button>
    <button class="btn btn_border close">关闭</button>
</div>
<script>

    (function () {
        $(".radio").click(function () {
            if($(this).val()==1){
                $("#radio1").show();
                $("#radio2").hide();
                $("#radio3").hide()
            }else{
                $("#radio1").hide();
                $("#radio2").show();
                $("#radio3").show()
            }
        });
        var pid = '${pid}',
                win = $('#' + pid),
                form = win.find('form');

        win.find('button.ok').click(function () {
            form.form('submit', {
                url: '${contextPath}/security/hdw/exchange_packet/create.htm',
                onSubmit: function (param) {
                    var price = $('#price_${pid}').numberspinner('getValue');
                    param.price = parseInt(Math.round(price * 100));
                    return true;
                },
                success: function (text) {
                    var json = $.evalJSON(text);
                <@app.json_jump/>
                    if (json.success) {
                        $.messager.alert('提示信息', '操作成功', 'info');
                        win.window('close');
                    } else {
                        $.messager.alert('提示信息', json.message, 'info');
                    }
                }
            });

        });
        win.find('button.close').click(function () {
            win.window('close');
        });
    })();
</script>
